package sample.util;

import javafx.scene.control.Alert;
import javafx.scene.image.Image;
import javafx.stage.Stage;

/**
 * @author ml
 * @create 2017-11-16--15:23
 */
public class Dialogutil {

    /**
     * 提示框
     * @param title
     * @param content
     */
    public static void InformationDialog(String title,String content){
        BasicDialog(Alert.AlertType.INFORMATION,title,content);
    }

    /**
     * 警告
     * @param title
     * @param content
     */
    public static void WariningDialog(String title,String content){
        BasicDialog(Alert.AlertType.WARNING,title,content);
    }

    /**
     * 错误
     * @param title
     * @param content
     */
    public static void ErrorDialog(String title,String content){
        BasicDialog(Alert.AlertType.ERROR,title,content);

    }

    /**
     * 基本展示
     * @param alertType
     * @param title
     * @param content
     */
    public static void BasicDialog(Alert.AlertType alertType,String title,String content){
        Alert alert=new Alert(alertType);
        alert.setTitle(title);
        alert.setHeaderText(null);
        alert.setContentText(content);

        Stage stage= (Stage) alert.getDialogPane().getScene().getWindow();
        stage.getIcons().add(new Image("sample/images/提示.png"));

        alert.showAndWait();
    }


}
